// Vue
import Vue from 'vue'
import App from './App'
// 核心插件
import ycAdmin from '@/plugin/ycAdmin'
// store
import store from '@/store/index'

// 菜单和路由设置
import router, { constantRoutes } from './router'

import { menuHeader } from '@/menu'
import permission from '@/directive/permission'

// 核心插件
Vue.use(ycAdmin)
Vue.use(permission)

new Vue({
    router,
    store,
    render: h => h(App),
    created () {
        // 处理路由 得到每一级的路由设置
        this.$store.commit('ycAdmin/page/init', constantRoutes)
        // 设置顶栏菜单
        this.$store.commit('ycAdmin/menu/headerSet', menuHeader)
    },
    mounted () {
        // 用户登录后从数据库加载一系列的设置
        this.$store.dispatch('ycAdmin/sys/load')
        // 获取并记录用户 UA
        this.$store.commit('ycAdmin/ua/get')
        // 初始化全屏监听
        this.$store.dispatch('ycAdmin/fullscreen/listen')
    }
}).$mount('#app')
